/**  
 * @Title: AjaxRequest.java
 * @Package com.limit.control.admin
 * @author maoyun(maoyun0903@163.com)
 * @date 2014-4-2 下午10:44:53
 * @version V1.0
 */ 
package com.limit.control.admin;

import java.util.List;

import com.jfinal.core.Controller;
import com.jfinal.kit.JsonKit;
import com.limit.model.Admin;
import com.limit.model.Game;
import com.limit.model.Rank;

/** 
 * 处理Ajax请求,不受后台AOP权限控制<br/>
 * @author maoyun(maoyun0903@163.com)
 * @date 2014-4-2 下午10:44:53 
 * @version V1.0
 */

public class AjaxController extends Controller {

	/**
	 * 检测登陆名
	 */
	public void checkUserName(){
		String username = this.getPara("username");
		boolean flag = Admin.dao.isExistUserName(username);
		this.renderJson("result", flag);
	}
	
	/**
	 * 正常显示的排行榜
	 */
	public void getRanks(){
		List<Rank> ranks = Rank.dao.getViewList();
		this.renderJson(JsonKit.listToJson(ranks, 2));
	}
	
	/**
	 * CP上架的游戏产品列表
	 */
	public void getGames(){
		long admin_id = this.getParaToLong("admin_id", 0L);
		List<Game> games = Game.dao.getListByAdminId(admin_id);
		this.renderJson(JsonKit.listToJson(games,2));
	}
	
	
	
}
